<template>
  <div class="app-container">
    <!-- 文档跳转按钮 -->
    <el-button icon="el-icon-document" type="primary" round @click="showLock">跳转文档</el-button>

    <!-- Curl Command 输入区 -->
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>发送自定义Curl请求</span>
      </div>
      <el-form :model="form" ref="form" label-width="100px">
        <el-form-item label="Curl-bash命令">
          <el-input type="textarea" v-model="form.curlCommand" placeholder="请输入或粘贴Curl命令"></el-input>
        </el-form-item>
        <el-form-item label="执行次数">
          <el-input-number v-model="form.count" :min="1" :max="100" label="执行次数"></el-input-number>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm">提交</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>


<script>
import { safe } from '@/api/cd/send';

export default {
  name: "send",
  data() {
    return {
      form: {
        curlCommand: '',
        count: 10,
      },
    };
  },
  methods: {
    submitForm() {
      const { curlCommand, count } = this.form;

      safe(
        { curlCommand },   // body 数据
        { count }          // query 参数
      ).then(response => {
        this.$message.success("请求已成功发送");
      }).catch(error => {
        this.$message.error("请求发送失败：" + error.message);
      });
      // this.$axios.post('/send/safe', {curlCommand: this.form.curlCommand}, {
      //   params: {
      //     count: this.form.count
      //   }
      // }).then(response => {
      //   this.$message.success("请求已成功发送");
      // }).catch(error => {
      //   this.$message.error("请求发送失败：" + error.message);
      // });
      }
  },
};
</script>

<style scoped>
.box-card {
  margin-top: 20px;
}
</style>